//
//  DYPaymentcodeView.m
//  kafuMerchant
//
//  Created by 帝云科技 on 2018/9/12.
//  Copyright © 2018年 帝云科技. All rights reserved.
//

#import "DYPaymentcodeView.h"

@interface DYPaymentcodeView ()

@property (nonatomic,strong) UIView *bgView;
@property (nonatomic,strong) UIImageView *codeImageView;
@property (nonatomic,strong) UIButton *nameButton;
@property (nonatomic,strong) UILabel *titleLabel;

@property (nonatomic,strong)UIButton *scanButton;
@property (nonatomic,strong)UIButton *payCodeButton;

@end


@implementation DYPaymentcodeView

-(instancetype)initWithFrame:(CGRect)frame
{
    self=[super initWithFrame:frame];
    if (self) {
        [self initUI];
    }
    return self;
}
-(void)initUI
{
    
    self.bgView = ({
        UIView *view=[[UIView alloc]init];
        view.backgroundColor=WhiteColor;
        [view xhq_cornerRadius:10];
        view;
    });
    
    self.nameButton = ({
    
        UIButton *button=[Utils createBtnWithType:UIButtonTypeCustom backgroundColor:ClearColor title:@"名称" image:nil font:15 textColor:[UIColor xhq_aTitle]];
        button;
    });
    
    self.codeImageView = ({
       
        UIImageView *imageView=[Utils imageView];
        imageView;
        
    });
    
    self.titleLabel= ({
        UILabel *label=[Utils labelWithTitle:@"使用卡福扫二维码，向我付款" titleFontSize:17 textColor:[UIColor xhq_content] backgroundColor:ClearColor alignment:1];
        label;
    });
    
    [self addSubview:self.bgView];
    
    [self.bgView addSubview:self.nameButton];
    [self.bgView addSubview:self.codeImageView];
    [self.bgView addSubview:self.titleLabel];
    
    [self addSubview:self.scanButton];
    [self addSubview:self.payCodeButton];
    
    [self.bgView makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.top.equalTo(BILIHEIGHT(30));
        make.size.equalTo(CGSizeMake(BILIWIDTH(337), BILIHEIGHT(389)));
    }];
    
    [self.nameButton makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(BILIHEIGHT(27));
        make.centerX.equalTo(self.bgView);
    }];
    
    [self.codeImageView makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.nameButton.bottom).offset(BILIHEIGHT(35));
        make.width.height.equalTo(BILIHEIGHT(180));
        make.centerX.equalTo(self.bgView);
    }];
    
    [self.titleLabel makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.codeImageView.bottom).offset(BILIHEIGHT(35));
        make.centerX.equalTo(self.bgView);
    }];
    
    [self.scanButton makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(kScreenWidth/2-BILIWIDTH(95));
        make.top.equalTo(self.bgView.bottom).offset(BILIHEIGHT(30));
        make.size.equalTo(CGSizeMake(BILIWIDTH(90), BILIWIDTH(90)));
    }];
    
    [self.payCodeButton makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.scanButton.right).offset(BILIWIDTH(10));
        make.centerY.equalTo(self.scanButton);
        make.size.equalTo(self.scanButton);
    }];
    
    [self.nameButton placeImageTitlePosition:ZYButtonImagePositionLeft space:BILIWIDTH(5)];
    [self.scanButton placeImageTitlePosition:ZYButtonImagePositionTop space:BILIHEIGHT(10)];
    [self.payCodeButton placeImageTitlePosition:ZYButtonImagePositionTop space:BILIHEIGHT(10)];
    
    self.codeImageView.backgroundColor=[UIColor xhq_red];
    
}
-(void)buttonClick:(UIButton *)button
{
    
}
-(UIButton *)scanButton
{
    if (!_scanButton) {
        _scanButton=[Utils createBtnWithType:UIButtonTypeCustom backgroundColor:ClearColor action:@selector(buttonClick:) target:self title:@"扫一扫" image:@"icon_s_scan" font:14 textColor:[UIColor colorWithWhite:1 alpha:0.5]];
        
//        _scanButton.frame=CGRectMake(kScreenWidth/2-BILIWIDTH(95), BILIHEIGHT(420+35), BILIWIDTH(90), BILIWIDTH(80));
       
    }
    return _scanButton;
}
-(UIButton *)payCodeButton
{
    if (!_payCodeButton) {
        _payCodeButton=[Utils createBtnWithType:UIButtonTypeCustom backgroundColor:ClearColor action:@selector(buttonClick:) target:self title:@"收款码" image:@"icon_gathering" font:14 textColor:WhiteColor];
        
//        _payCodeButton.frame=CGRectMake(kScreenWidth/2+BILIWIDTH(5), BILIHEIGHT(420+35), BILIWIDTH(90), BILIWIDTH(80));
      
    }
    return _payCodeButton;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
